﻿using System;
using System.Collections.Generic;
using Kugar.Core.ExtMethod;
using Kugar.ERPFramework.Core.Interfaces;

namespace Kugar.ERPFramework.BLLInterface.Session
{
    public class SessionItem
    {
        public SessionItem(string sessionID)
        {
            SessionID = sessionID;
        }

        private Dictionary<string, object> _cacheValue = new Dictionary<string, object>(5);

        public DateTime LastActiveTime { get; private set; }

        public IProjectInstance CurrentInstance { get; internal set; }

        public object this[string key]
        {
            get { return _cacheValue.TryGetValue(key); }
            set { _cacheValue.AddOrUpdate(key, value); }
        }

        public int UserID { get;  set; }

        public string SessionID { get; private set; }

        public void Active()
        {
            LastActiveTime = DateTime.Now;
        }
    }
}